package com.training.hatton.dropboxclient.utill;

import java.text.MessageFormat;

import org.apache.http.client.methods.HttpRequestBase;


public class Signer {

	private static final String SIGN_TEMPLATE = "OAuth oauth_version=\"1.0\", oauth_signature_method=\"PLAINTEXT\", oauth_consumer_key=\"{0}\",oauth_token=\"{1}\",oauth_signature=\"{2}&{3}\"";
	
	private static final String AUTHORIZATION = "Authorization";

	
	public static void sign(HttpRequestBase request) {
		String headerValue = MessageFormat
				.format(SIGN_TEMPLATE, 
						DropboxService.APP_KEY, 
						DropboxService.getAccess_token(), 
						DropboxService.APP_SECRET, 
						DropboxService.getAccess_token_secret());
		request.addHeader(AUTHORIZATION, headerValue);
	}
}
